<template>
  <van-search
    v-model="wd"
    placeholder="请输入搜索关键词"
    input-align="center"
    shape="round"
    background="#4fc08d"
    show-action
    @search="onSearch"
  >
    <template #action>
      <div @click="onSearch">搜索</div>
    </template>
  </van-search>
</template>

<script setup>
import { ref } from "vue"
import { Toast } from 'vant';

const wd = ref("")
// const emit = defineEmits(["event1", "event2"])
const emit = defineEmits(["onSearch"])
const onSearch = () => {
  if(!wd.value) {
    Toast("关键词不能为空！")
    return
  }
  emit("onSearch", wd.value)
  // this.$emit("event", {})
}

</script>

<!--
<script>
import { ref } from "vue"

export default {
  name: "MusicSearch",
  setup() {
    const wd = ref("")
    return {
      wd
    }
  }
}
</script>-->
